﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartlForm.Model
{
    /// <summary>
    /// 结果状态
    /// </summary>
    public class Result
    {
        public int ret { get; set; }
        public string msg { get; set; }
        public object data { get; set; }
    }

    /// <summary>
    /// 状态码
    /// </summary>
    public enum Status
    {

        /// <summary>
        /// 成功
        /// </summary>
        SUCCESS_CODE = 200,
        /// <summary>
        /// 错误
        /// </summary>
        ERROR_CODE = 400,
        /// <summary>
        /// 授权失败
        /// </summary>
        AUTH_FAIL = 401,
        /// <summary>
        /// 登陆无效
        /// </summary>
        LOGIN_INVALID_CODE = 402,
        /// <summary>
        /// 失败
        /// </summary>
        FAIL_DATA = 403,
        /// <summary>
        /// 数据为空
        /// </summary>
        NULL_DATA = 404,
        /// <summary>
        /// 不是会员
        /// </summary>
        NOT_MEMBER = 500,
        /// <summary>
        /// 会员续费通知
        /// </summary>
        MEMBER_RENEW = 501
    }


    /// <summary>
    /// 结果状态
    /// </summary>
    public class ResultHelper
    {
        public static Result Success(string msg = null, object data = null)
        {
            return new Result() { ret = Convert.ToInt32(Status.SUCCESS_CODE), msg = msg, data = data };
        }

        public static Result Error(string msg, object data = null)
        {
            return new Result() { ret = Convert.ToInt32(Status.ERROR_CODE), msg = msg, data = data };
        }

        public static Result Code(Status ret,string msg, object data = null)
        {
            return new Result() { ret = Convert.ToInt32(ret), msg = msg, data = data };
        }
    }
}
